package org.suze.demo.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.suze.demo.entity.Student;
import org.suze.demo.facade.StudentFacade;
import org.suze.demo.form.StudentForm;
import org.suze.demo.vo.StudentVo;
import org.suze.framework.base.Result;
import org.suze.framework.base.page.PageForm;
import org.suze.framework.base.page.PageVO;

/**
 * @description:
 * @Date : 2020/6/16 21:42
 * @Author : Seig Heil
 */
@RestController
@RequestMapping("/student")
@Api(description = "学生管理",tags = "学生管理")
public class StudentController {

    @Autowired
    StudentFacade studentFacade;

    @PostMapping("/loadRecords")
    @ApiOperation("分页查询")
    public Result<PageVO<StudentVo>> loadRecords(@RequestBody PageForm<StudentForm> form){
        return studentFacade.loadRecords(form);
    }

    @PostMapping("/saveRecord")
    @ApiOperation("保存记录")
    public Result<String> saveRecord(@RequestBody Student student){
        return studentFacade.saveRecord(student);
    }

    @GetMapping("/deleteRecord/{id}")
    @ApiOperation("删除记录")
    public Result<String> deleteRecord(@PathVariable Integer id){
        return studentFacade.deleteRecord(id);
    }

    @GetMapping("/queryRecord/{id}")
    @ApiOperation("查询详情")
    public Result<String> queryRecord(@PathVariable Integer id){
        return studentFacade.queryRecord(id);
    }
}
